<?php
require_once(dirname(__FILE__)."/../core/safeParam.php");
if($_GET['plugin'] == ""){
  // no plugin specified, show the list of plugins.
  $path = '../modules/plugins/';
  $results = scandir($path);

  foreach ($results as $result) {
      if ($result === '.' or $result === '..' ) continue;

      if (is_dir($path . '/' . $result)) {
       $folders .= '<tr><td>'.$result.'</td><td><a href="index.php?edit=plugins&plugin='.$result.'">Edit plugin</a></td></tr>';
      }
  }
  echo '<table cellspacing="2" cellpadding="2" border="0" class="table">
          <tr>
            <th>Plugin Name</th>
            <th>View</th>
          </tr>';
  echo "$folders";
} else {
  // display the plugin 
  include '../modules/plugins/'.$_GET['plugin'].'/admin.php';
}
?>
